//
//  ChooseTextView.m
//  Cxzc
//
//  Created by hwd on 17/8/7.
//  Copyright © 2017年 张露杰. All rights reserved.
//

#import "ChooseTextView.h"


@implementation ChooseTextView

-(instancetype)initWithFrame:(CGRect)frame Title:(NSString *)title PlaceHodel:(NSString *)hodelStr Content:(NSString *)contentStr ChooseImageV:(NSString *)imageStr
{
    if (self = [super initWithFrame:frame]) {//先加载父类
        self.backgroundColor = [UIColor whiteColor];
        [self.layer setCornerRadius:5*screenW_6];
        self.layer.masksToBounds = YES;
        
        if (!_titleLab) {
            
            //标题
            _titleLab = [TomamaUI createLabel:CGRectMake(20*screenW_6, 0, 80*screenW_6, 50*screenW_6) textAligment:0 font:[UIFont systemFontOfSize:15*screenW_6] textColor:TextBlack text:title];
            [self addSubview:_titleLab];
            
            float startXNumber = 20*screenW_6;
            if (![title isEqualToString:@""]) {//不存在title
                startXNumber = 100*screenW_6;
            }
            //输入框
            _titleTf = [[UITextField alloc]initWithFrame:CGRectMake(startXNumber,0,self.frame.size.width-60*screenW_6,self.frame.size.height)];
            _titleTf.font = [UIFont systemFontOfSize:15*screenW_6];
            _titleTf.returnKeyType =  UIReturnKeyDefault;
            [_titleTf setValue:[UIColor lightGrayColor] forKeyPath:@"_placeholderLabel.textColor"];
            _titleTf.textColor = [UIColor blackColor];
            _titleTf.text = contentStr;
            _titleTf.placeholder = hodelStr;
            _titleTf.enabled = NO;
            [self addSubview:_titleTf];
            
            //选择按钮
            _chooseImageV = [[UIImageView alloc]init];
            _chooseImageV.image = [UIImage imageNamed:imageStr];
            _chooseImageV.frame = CGRectMake(SCREENW-20*screenW_6-_chooseImageV.image.size.width,frame.size.height/2-_chooseImageV.image.size.height/2, _chooseImageV.image.size.width,_chooseImageV.image.size.height);
            [self addSubview:_chooseImageV];
            
            [self addSubview:[ToolViewVC addCellLineLab:CGRectMake(15*screenW_6, 49*screenW_6, SCREENW-30*screenW_6, 1*screenW_6)]];
            
        }
        _titleTf.text = contentStr;
    }
    return self;
}

@end
